<?php
use yii\helpers\Html;
use yii\widgets\DetailView;

$models = $model->flight; // Table OrderRoom
?>

<?=  yii\web\View::registerCssFile("/css/magic-check.css",['depends' => 'app\assets\AppAsset']) ?>

<div class="col-md-offset-1 col-md-10 panel panel-body" style="margin-top:30px;">
    <p><label> 机票信息 </label></p>

    <?php foreach($models as $mk=>$flight){ ?>
    <div class="row">
        <div class="col-md-2" >
            <?= $flight->productFlight->name ?> |  
            <?= $flight->productFlight->price ?> 
        </div>
        <div class="col-md-2">人数 : <?= $flight->price ?></div>
        <div class="col-md-8">
            <?php foreach($customers as $customer){ ?>
            <?php $key = $flight->id.$customer->id; ?>
            <div style="float:left;margin-right:15px;">
                <input type="hidden" class="flight-id" value="<?= $flight->id?>">
                <input type="hidden" class="customer-id" value="<?= $customer->id?>">
                <input class="magic-checkbox flight-magic" <?= ($customer->id == $flight->customer_id) ? 'checked' : '';  ?> type="radio" id="flight<?= $key ?>" name="flight<?= $flight->id?>">
                <label for="flight<?= $key ?>" >
                    <?= $customer->first_name . $customer->last_name ?>
                </label>
            </div>
            <?php } ?>
        </div>
    </div>
    </br>
    <?php } ?>

</div>

<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">
    /**  add Loading  **/
    $(".flight-magic").click(function(){
        var flight_id = $(this).siblings('.flight-id').val(); // 获取机票订单ID
        var customer_id = $(this).siblings('.customer-id').val(); // 获取客户编号
        var checked = $(this).is(':checked');   // 是否选中
        
        $.get("/order/flight/save", {customer_id:customer_id,flight_id:flight_id,checked:checked}, function(){
            
        });
    });
            
</script>
<?php app\components\JsBlock::end() ?>
